package com.the_ring.structural.composite;

import java.util.ArrayList;

/**
 * @author: t22306139
 * @date: 2023/12/1  10:28
 */
public class Composite implements Component{

    private ArrayList<Component> children = new ArrayList<>();

    public void add(Component c) {
        children.add(c);
    }

    public void remove(Component c) {
        children.remove(c);
    }

    public Component getChild(int i) {
        return children.get(i);
    }

    @Override
    public void operation() {
        for (Component obj : children) {
            obj.operation();
        }
    }
}
